package com.ibm.risk.irmp.data.table.rest;

import com.ibm.risk.irmp.data.table.entity.DataTable;
import com.ibm.risk.irmp.data.table.entity.DataTableColumn;
import com.ibm.risk.irmp.data.table.service.IDataTableQueryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v2/data-table")
public class DataTableController {

    @Autowired
    IDataTableQueryService tableDefQueryService;

    @GetMapping("/tables/groups/{groupCode}")
    public List<DataTable> getTablesByGroup(@PathVariable String groupCode) {
        return tableDefQueryService.getTableListByGroup(groupCode);
    }

    @GetMapping("/cols/tables/{tableCode}")
    public List<DataTableColumn> getTableCols(@PathVariable String tableCode) {
        return tableDefQueryService.getTableColumnDefListByTableCode(tableCode);
    }

}
